
package com.ddyx.service.user.api.feign.factory;

import com.ddyx.service.user.api.feign.RemoteUserClient;
import com.ddyx.service.user.api.feign.fallback.RemoteUserClientFallback;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * SpringCloud Feign通过FallbackFactory可以显示异常信息
 * 		Feign可以进行服务消费，而且内置了Hystrix，能够进行熔断。
 * author: agula
 * since: 2019-08-01
 */
@Component
public class RemoteUserClientFallbackFactory implements FallbackFactory<RemoteUserClient> {

	@Override
	public RemoteUserClient create(Throwable throwable) {
		RemoteUserClientFallback userClientFallback = new RemoteUserClientFallback();
		userClientFallback.setCause(throwable);
		throwable.printStackTrace();//打印下异常
		return userClientFallback;
	}
}
